package com.ruoyi.test.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.common.utils.StringUtils;
import java.util.List;
import java.util.Map;
import com.ruoyi.test.mapper.ClassroomMapper;
import com.ruoyi.test.domain.Classroom;
import com.ruoyi.test.service.IClassroomService;

/**
 * 班级Service业务层处理
 *
 * @author korol
 * @date 2023-11-11
 */
@Service
public class ClassroomServiceImpl extends ServiceImpl<ClassroomMapper, Classroom> implements IClassroomService {

    @Autowired
    private ClassroomMapper classroomMapper;

    /**
     * 查询班级列表
     *
     * @param classroom 班级
     * @return 班级
     */
    @Override
    public List<Classroom> selectClassroomList(Classroom classroom)
    {
        List<Classroom> classroomList = classroomMapper.selectList(buildQueryWrapper(classroom));
        return classroomList;
    }


    private LambdaQueryWrapper<Classroom> buildQueryWrapper(Classroom query) {
        Map<String, Object> params = query.getParams();
        LambdaQueryWrapper<Classroom> lqw = Wrappers.lambdaQuery();
        lqw.like(StringUtils.isNotBlank(query.getName()), Classroom::getName, query.getName());
        lqw.eq(StringUtils.isNotBlank(query.getNumber()), Classroom::getNumber, query.getNumber());
        lqw.orderByDesc(Classroom::getCreateTime);
        return lqw;
    }

}
